
#pragma once

#include <map>
#include <string>
#include <vector>

#include "CxType.h"
#include "CxTime.h"
#include "CxUnitBulb.h"
#include "CxMachineUtility.hpp"



BEGIN_NAMESPACE(MSG_SIGN)

using std::string;
using std::vector;
using std::map;

struct	showMode
{
	typedef     unsigned short				_Word;

	bool			b_ispicSeq;
	bool			b_staytimeUnit;

	_Word			m_showSpeed;
	_Word			m_showmodeIn;
	_Word			m_showmodeOut;
	_Word			m_timeshowMode;
	_Word			m_timeshowPos;
	size_t			m_staytime;

	showMode():b_ispicSeq(false),b_staytimeUnit(false)
	{}
};

struct tmpOption
{
	typedef     unsigned short				_Word;
	typedef		unsigned char				_Byte;

	_Byte		m_tmppowerMax;
	_Byte		m_tmppowerMin;
	_Byte		m_tmpfanMax;
	_Byte		m_tmpfanMin;

	bool		b_isautoOff;
	bool		b_isautoFan;
	bool		b_isautoPower;
	bool		b_issmokeautoOff;

	tmpOption():m_tmppowerMax(60),m_tmppowerMin(25),m_tmpfanMax(60),m_tmpfanMin(25),
		b_isautoOff(false),b_isautoFan(false),b_isautoPower(false),b_issmokeautoOff(false)
	{
	}
};


struct	relyOption
{
	bool		b_power;
	bool		b_fan;
};

class CxUnitCard
{
protected:	
	
	typedef		boost::posix_time::ptime	_Date;
	typedef		std::vector<unsigned char>	_Data;
	typedef		unsigned int				CardID;
	typedef		vector< vector<CxBulb*> >	_Bulb;
	typedef		utility::CxImage			_Image;

	typedef		unsigned char				_Byte;
	typedef		unsigned short				_Word;
public:

	CxUnitCard(size_t  cardid, int  cx=64, int cy=16);
	virtual	~CxUnitCard();

public:

	void		revpartImage(int  ,int  ,const _Data &);

	void		showText(const string & ){}

	void		drawLine(int ,int ,int  ,int ,int ){}
	
	void		protectZH(bool	){}
	void		setLight(_Byte light){m_light=light;}

	void		rdlosepointData(_Data &){}

	//power  interface
	void		rdpowerDetect(_Data &){}

	void		rdworkState(_Data &);

	void		setProgram(int  ){}

	void		setautoSwitch(_Date ,_Date ,_Date ,_Date ){}

private:

	void		buildPart();

	CxBulb	*getBulb(int x,int y)
	{
		try
		{
			return m_bulb.at(x).at(y);
		}
		catch(std::exception &)
		{
			CX_ERR_MESSAGE("STDERROR")
			return NULL;
		}
	}

public:
	void			setShowMode(const showMode &mode)
	{
		m_showMode=mode;
	}
	void			settmpOption(const tmpOption &option)
	{
		m_tmpOption=option;
	}
	void			setRely(bool		power,bool		fan)
	{
		m_rely.b_power=power;
		m_rely.b_fan=fan;
	}
private:

	showMode		m_showMode;
	tmpOption		m_tmpOption;
	relyOption		m_rely;

	_Byte			m_light;
	_Word			m_nloseEff;


	_Word			m_currentPlay;

	CardID			m_id;
	int				m_width;
	int				m_height;
	_Bulb			m_bulb;
	map<size_t , _Image*>		m_image;
};

END_NAMESPACE 